<template>
  <view>
    <!-- 顶部自定义导航 -->
    <tn-nav-bar fixed alpha customBack>
      <view slot="back" class='tn-custom-nav-bar__back'
        @click="goBack">
        <text class='icon tn-icon-left'></text>
      </view>
    </tn-nav-bar>
	
	<view class="setting-list" :style="{marginTop: vuex_custom_bar_height + 'px'}">
		
		<tn-button :disabled="loading" :loading="loading" shape="round" backgroundColor="tn-main-gradient-bluepurple--reverse" padding="40rpx 0" width="100%" fontBold @click="logout">
		  <text class="tn-color-white" hover-class="tn-hover" :hover-stay-time="150">
		    登 出
		  </text>
		</tn-button>
	</view>
  </view>
</template>

<script>
  import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
  import { mapState } from 'vuex'
  import { logout as logoutApi } from '@/api/auth'
  export default {
    name: 'Setting',
    mixins: [template_page_mixin],
    data() {
      return {
		loading: false
      }
    },
    computed: {
      ...mapState(['vuex_custom_bar_height', 'vuex_token']),
    },
    methods: {
      logout() {
        this.loading = true
        logoutApi().finally(() => {
          this.$t.vuex('vuex_token', null)
          this.$t.vuex('vuex_self', null);
          this.loading = false
          uni.reLaunch({
            url: '/minePages/login'
          })
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  /* 胶囊*/
  .tn-custom-nav-bar__back {
    width: 60%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    box-sizing: border-box;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 1000rpx;
    border: 1rpx solid rgba(255, 255, 255, 0.5);
    color: #FFFFFF;
    font-size: 18px;
    
    .icon {
      display: block;
      flex: 1;
      margin: auto;
      text-align: center;
    }
  }
  .setting-list {
	  padding: 30rpx 51rpx;
  }

  /* 底部悬浮按钮 start*/
  .tn-tabbar-height {
    min-height: 100rpx;
    height: calc(120rpx + env(safe-area-inset-bottom) / 2);
  }

  .tn-footerfixed {
    position: fixed;
    width: 100%;
    bottom: calc(30rpx + env(safe-area-inset-bottom));
    z-index: 1024;
    box-shadow: 0 1rpx 6rpx rgba(0, 0, 0, 0);
  }
  /* 底部悬浮按钮 end*/
  
</style>
